import * as orderApi from "../../api/order_manage";

const orderManage = {
  namespaced: true,
  state: {},
  mutations: {},
  actions: {
    async getOrderList({ commit }, searchObj) {
      let respData = await orderApi.getOrderList(searchObj);
      respData = respData.data;
      return new Promise((resolve, reject) => {
        resolve(respData);
      });
    },
    async updateOrderPrice({ commit }, priceInfo) {
      let respData = await orderApi.updateOrderPrice(
        priceInfo.orderId,
        priceInfo.price
      );
      respData = respData.data;
      return new Promise((resolve, reject) => {
        resolve(respData);
      });
    },
    async getAvaliableEmployees({ commit }, searchObj) {
      let respData = await orderApi.getAvaliableEmployees(searchObj);
      respData = respData.data;
      return new Promise((resolve, reject) => {
        resolve(respData);
      });
    },
    async updateOrderEmploy({ commit }, updateObj) {
      let respData = await orderApi.updateOrderEmployee(updateObj);
      respData = respData.data;
      return new Promise((resolve, reject) => {
        resolve(respData);
      });
    },
    async getOrderTasks({ commit }, orderId) {
      let respData = await orderApi.getOrderTasks(orderId);
      respData = respData.data;
      return new Promise(resolve => {
        resolve(respData);
      });
    },
    /**
     * 手动更新订单支付状态
     */
    async updatePayStatus({ commit }, params) {
      let respData = await orderApi.updatePayStatus(params);
      respData = respData.data;
      return new Promise(resolve => {
        resolve(respData);
      });
    }
  }
};

export default orderManage;
